package cn.zhuama.common.component;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfigurer implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptorJWT loginInterceptor;
    
    // 这个方法用来注册拦截器，我们自己写好的拦截器需要通过这里添加注册才能生效【路劲】

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
                registry.addInterceptor(loginInterceptor)
                //拦截所有请求
                .addPathPatterns("/**")
//                //放行跟登录的请求
                .excludePathPatterns("/login/**")
//                //放行跟注册有关的
                .excludePathPatterns("/user/*/register","/verifyCode/**")
                .excludePathPatterns("/shop/settlement","/fastdfs")

               //放行swagger
                .excludePathPatterns("/swagger-resources/**", "/webjars/**",
                        "/v2/**", "/swagger-ui.html/**")
                        .excludePathPatterns(
                                "/static/**",
                                "/css/**",
                                "/js/**",
                                "/images/**",
                                "/favicon.ico",
                                "/error"
                        );
                 //如果写了邮箱激活还要放行邮箱
    }


}